function mousOver(t) {
    var menu = t.getElementsByClassName("jq_hidebox")[0];
    menu.style.display = "block";

    var icon_arr = t.getElementsByClassName("icon_arr")[0];
    icon_arr.style.border = "1px solid #dfdfdf";
    icon_arr.style.borderBottom = "none";
    icon_arr.style.backgroundColor = "#fff";
}


function mousOut(t) {
    var menu = t.getElementsByClassName("jq_hidebox")[0];
    menu.style.display = "none";

    var icon_arr = t.getElementsByClassName("icon_arr")[0];
    icon_arr.style.border = "none";
    icon_arr.style.color = "#666"
}

var switchDisplayNum = 1;
function switchDisplay(t) {
    var sw = document.getElementById("registerVO.password");
    var showPwd = document.getElementById("showPwd");

    switchDisplayNum++;
    if (switchDisplayNum == 2) {
        sw.style.display = "none";
        showPwd.style.display = "block";
        showPwd.value = sw.value;
        t.style.backgroundImage = "url(../img/icon-visible.png)"
    }
    var val = showPwd.value;

    if (switchDisplayNum == 3) {
        sw.style.display = "block";
        sw.value = val;
        showPwd.style.display = "none";
        t.style.backgroundImage = "url(../img/icon-invisible.png)"
        switchDisplayNum = 1;
    }
}

var checkSwitch = 1;
function check(t) {
    var regbtn = document.getElementById("regbtn");
    checkSwitch++;
    if (checkSwitch == 2) {
        regbtn.removeAttribute("disabled");
    }

    if (checkSwitch == 3) {
        regbtn.setAttribute("disabled", true);
        checkSwitch = 1;
    }
}

/**
 * 手机号有效性验证
 */
function phoneVerification(t) {
    var p = /^\d{1,30}$/
    var spanofficephoneinfo = document.getElementById("spanofficephoneinfo");
    var val = t.value;
    if (val == "") {
        spanofficephoneinfo.innerHTML = "手机号码不能为空。";
    } else {
        spanofficephoneinfo.innerHTML = "";
        if (p.test(val)) {
            if (val.length < 6 || val.length > 30) {
                spanofficephoneinfo.innerHTML = "手机号码长度不能小于6且不能大于30。";
            } else {
                var img = document.createElement("img");
                spanofficephoneinfo.appendChild(img);
                img.src = "../img/icons_right.png";
            }
        } else {
            spanofficephoneinfo.innerHTML = "手机号码格式无效。";
        }
    }
}

/**
 *密码有效性验证
 *
 */
function pwVerification(t) {
    var teshu = /[~!@#$%^&*()_\-+=<>?:"{}|]{1,}/;
    var kongge = /\s{1,}/;
    var zimu = /[a-zA-Z]{1,}/;
    var p = /^\d{1,30}$/;
    var zhongwen = /[\u4e00-\u9fa5]|[^\x00-\xff]{1,}/;

    var spanpwdinfo = document.getElementById("spanpwdinfo");
    var val = t.value;
    if (val == "") {
        spanpwdinfo.innerHTML = "密码不能为空。";
    } else {
        spanpwdinfo.innerHTML = "";
        if (zhongwen.test(val)) {
            spanpwdinfo.innerHTML = "密码中不能包含中文或其他多字节字符。";
        } else {
            spanpwdinfo.innerHTML = "";
            if (kongge.test(val)) {
                spanpwdinfo.innerHTML = "密码前后不能有空格字符。";
            } else {
                if (val.length < 8) {
                    spanpwdinfo.innerHTML = "密码长度不能小于8位。";
                } else {
                    spanpwdinfo.innerHTML = "";
                    if (!zimu.test(val)) {
                        spanpwdinfo.innerHTML = "密码必须包含至少一个字母。";
                    } else {
                        spanpwdinfo.innerHTML = "";
                        if (teshu.test(val)) {
                            spanpwdinfo.innerHTML = "";
                            var img = document.createElement("img");
                            spanpwdinfo.appendChild(img);
                            img.src = "../img/icons_right.png";
                        } else {
                            spanpwdinfo.innerHTML = "密码必须包含至少一个特殊字符。";
                        }
                    }
                }
            }
        }

    }
}


/**
 *验证码有效性验证
 *
 */
function verificationCode(t) {
    var kongge = /\s{1,}\w{1,}/;
    var verifyCapcodeinfo = document.getElementById("verifyCapcodeinfo");
    var val = t.value;
    if (val == "" || !kongge.test(val)) {
        verifyCapcodeinfo.innerHTML = "验证码不能为空。";
    } else {
        verifyCapcodeinfo.innerHTML = "";
    }
}




function country(t) {
    var val = t.value;
    var biaoshi = "";
    var code = document.getElementById("registerVO.countryCode");
    for (var index = val.indexOf("(") + 1; index < val.indexOf(")"); index++) {
        biaoshi = biaoshi + val[index];

    }
    code.value = biaoshi;
}

function inputCode(t) {
    var code = "";
    var name = "";
    var options = document.getElementsByTagName("option");
    var countryCodeSelect = document.getElementById("countryCodeSelect");

    // console.log("1");
    // console.log(options);
    for (let index = 0; index < options.length; index++) {
        for (let i = options[index].value.indexOf("(") + 1; i < options[index].value.indexOf(")"); i++) {
            code = code + options[index].value[i];
        }

        if (t.value == code) {
            console.log("匹配成功:" +t.value , code );
            for (let j = 0; j < options[index].value.indexOf("(") - 1; j++) {
                name = name + options[index].value[j];
            }
            console.log(name);
            
            options[index].selected = true;
            break;
        } else {
            countryCodeSelect.value = "其他";
            code = "";
        }

    }
}